#include <stddef.h>
#include <stdio.h>
#include <stdlib.h>

int main(void)
{
    struct s {
        int i;
        char c;
        double d;
        char a[];// must at the end of struct, C99
    };

    /* Output is compiler dependent */

    printf("offsets: i=%ld; c=%ld; d=%ld a=%ld\n",
            (long) offsetof(struct s, i),
            (long) offsetof(struct s, c),
            (long) offsetof(struct s, d),
            (long) offsetof(struct s, a));
    printf("sizeof(struct s)=%ld\n", (long) sizeof(struct s));
	struct s *p = (struct s *)malloc(sizeof(struct s)+100*sizeof(char));
	p->a[10] = 10;
	printf("p = %p,p->a[10] = %d, sizeof(*p)= %d\n",p,p->a[10],sizeof(*p));
	free(p);

    exit(EXIT_SUCCESS);
}


